package com.huya.mapper;

import com.github.pagehelper.Page;
import com.huya.pojo.dto.KnowledgePageQueryDTO;
import com.huya.pojo.entity.Knowledge;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface KnowledgeMapper {
    /**
     * 插入一条知识
     * @param knowledge
     */
    @Insert("insert into psychology_knowledge(title, content, category, cover, create_time) " +
            "values(#{title}, #{content}, #{category}, #{cover}, #{createTime})")
    void insert(Knowledge knowledge);

    /**
     * 批量删除
     * @param ids
     */
    void deleteByIds(List<Long> ids);

    /**
     * 分页查询
     * @param knowledgePageQueryDTO
     * @return
     */
    Page<Knowledge> pageQuery(KnowledgePageQueryDTO knowledgePageQueryDTO);

    /**
     * 根据id查询
     * @param id
     * @return
     */
    @Select("select * from psychology_knowledge where id = #{id}")
    Knowledge getById(Long id);

    /**
     * 更新
     * @param knowledge
     */
    void update(Knowledge knowledge);
}
